﻿Imports System.Windows.Controls.Primitives

Public Class EnvelopeZoomThumb
    Inherits Thumb

    Shared Sub New()
        DefaultStyleKeyProperty.OverrideMetadata(GetType(EnvelopeZoomThumb), new FrameworkPropertyMetadata(GetType(EnvelopeZoomThumb)))
    End Sub



    Public Property Value As Double
        Get
            Return DirectCast(GetValue(ValueProperty), Double)
        End Get
        Set(ByVal value As Double)
            SetValue(ValueProperty, value)
        End Set
    End Property

    Public Shared ReadOnly ValueProperty As DependencyProperty = DependencyProperty.Register( _
        "Value", GetType(Double), GetType(EnvelopeZoomThumb), _
            New FrameworkPropertyMetadata(8.0))



    Private origValue As Double

    Private Sub EnvelopeZoomThumb_DragStarted(sender As Object, e As DragStartedEventArgs) Handles Me.DragStarted
        origValue = Value
    End Sub

    Private Sub EnvelopeZoomThumb_DragDelta(sender As Object, e As DragDeltaEventArgs) Handles Me.DragDelta
        Dim _value = origValue + (e.HorizontalChange - e.VerticalChange) / 100
        If _value < 2 Then _value = 2
        If _value > 14 Then _value = 14
        Value = _value
    End Sub

End Class
